package com.sc.nft.entity.vo.ecology;


import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;
import java.util.List;


@Data
public class EcologyCastDetailsVO {


    @ApiModelProperty(value = "id")
    private Long id;

    @ApiModelProperty(value = "商品id")
    private Long productId;

    @ApiModelProperty(value = "详情页主图")
    private String productDetailPicture;

    @ApiModelProperty(value = "商品名称")
    private String productName;

    @ApiModelProperty(value = "商品总量")
    private Integer sumCount;

    @ApiModelProperty(value = "系列名称")
    private String catenaName;

    @ApiModelProperty(value = "发行方名称")
    private String daoName;

    @ApiModelProperty(value = "发行方图片")
    private String daoImage;

    @ApiModelProperty(value = "铸造须知")
    private String productPresentation;

    //    @ApiModelProperty(value = "是否可以铸造 0:不可以 1:可以")
    //    private Boolean type;

    @ApiModelProperty(value = "剩余数量")
    private Integer usableCount;

    @ApiModelProperty(value = "铸造方式List")
    private List<EcologyCastWayVO> wayList;

    @ApiModelProperty(value = "详情页图类型 1 图片 2:动图 3:3d模型")
    private Integer productDetailPictureType;

    @ApiModelProperty(value = "3D模型贴图")
    private String modelImg;

    @ApiModelProperty(value = "3D模型距离")
    private String modelDistance;

    @ApiModelProperty(value = "上限")
    private Integer upperLimit;

    @ApiModelProperty("是否锁仓")
    private Boolean isLockedPosition;

    @ApiModelProperty("锁仓描述")
    private String lockedPositionDescribe;

    @ApiModelProperty("锁仓类型 0:省缺 1:时间模式 2:日期形式 时间模式是获取藏品后延后多久,日期形式是统一锁到对应的时间")
    private Integer lockedPositionType;

    @ApiModelProperty("锁仓市场小时")
    @JsonIgnore
    private Integer lockedPositionHour;

    @ApiModelProperty("锁仓到期日期")
    //    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonIgnore
    private Date lockedPositionTime;

    @ApiModelProperty("用户可用数量")
    private Integer userUsableCount;

    @ApiModelProperty(value = "每熔炼一份添加铸造的次数")
    private Integer addCastCount;

    @ApiModelProperty(value = "是否熔炼了该藏品")
    private Boolean isHatch;

    @ApiModelProperty(value = "是否配置兑换上限")
    private Boolean convertibilityCeiling;
    
    @ApiModelProperty(value = "上链费消耗")
    private EcologyCastGasVO ecologyCastGas;

    public void setLockedPositionDescribe() {
        // 在是锁仓的情况下,根据类型进行描述
        if (this.isLockedPosition) {
            // 时间模式
            if (this.lockedPositionType.equals(1)) {
                if (this.lockedPositionHour != null) {
                    // 当时间不为空的时候,那么要把时间/24  把他变成几天几小时
                    int day = this.lockedPositionHour / 24;
                    int hour = this.lockedPositionHour % 24;
                    if (day > 0 && hour > 0) {
                        this.lockedPositionDescribe = StrUtil.format("冷却时间: {}天{}小时", day, hour);
                    } else if (day > 0 && hour == 0) {
                        this.lockedPositionDescribe = StrUtil.format("冷却时间: {}天", day);
                    } else if (day == 0 && hour > 0) {
                        this.lockedPositionDescribe = StrUtil.format("冷却时间: {}小时", hour);
                    }
                }
            }
            if (this.lockedPositionType.equals(2)) {
                if (this.lockedPositionTime != null) {
                    // 如果当前时间大于锁仓截止时间.那么就把是否锁仓设置为false
                    if (this.lockedPositionTime.getTime() < System.currentTimeMillis()) {
                        this.isLockedPosition = false;
                        this.lockedPositionDescribe = "冷却已到期";
                    } else {
                        this.lockedPositionDescribe = StrUtil.format("冷却结束时间: {}",
                                DateUtil.format(this.lockedPositionTime, "yyyy-MM-dd HH:mm:ss"));
                    }
                }
            }
        }
    }
}
